﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.ShprossesBuilder.Modelling.Components;

namespace ITAP.ShprossesBuilder.Operations
{
    public enum ShprossHeightOperation
    {
        IncreaseHeight,
        DecreaseHeight
    }

    public class OperationChangeShprossesHeight : IOperation
    {
        private ShprossHeightOperation heightOperation;
        public OperationChangeShprossesHeight(ShprossHeightOperation heightOperation)
        {
            this.heightOperation = heightOperation;
        }
        #region IOperation Members

        public string Name
        {
            get { return "Изменение высоты арок"; }
        }

        public OperationGroup OperationGroup
        {
            get { return OperationGroup.ShprossOperation; }
        }

        public System.Drawing.Image Thumbnail
        {
            get { return null; }
        }

        public void Execute(ModelControl modelControl)
        {
            foreach (IComponent selectedComponent in modelControl.ModelContainer.SelectedComponentsStack)
            {
                if (selectedComponent is Shpross)
                {
                    Shpross shpross = selectedComponent as Shpross;
                    if (shpross.Height == 0)
                        continue;

                    if (this.heightOperation == ShprossHeightOperation.IncreaseHeight)
                        shpross.Height += 1;
                    else if (this.heightOperation == ShprossHeightOperation.DecreaseHeight)
                        shpross.Height -= 1;
                }
            }
        }

        public bool CanUndo
        {
            get { return false; }
        }

        #endregion
    }
}
